package com.bot.nft.module.dc.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bot.common.pojo.CommonResult;
import com.bot.nft.module.dc.controller.DcSellInfoController;
import com.bot.nft.module.dc.domain.bo.DcSellInfoBo;
import com.bot.nft.module.dc.domain.bo.DcSellNftQueryBo;
import com.bot.nft.module.dc.domain.vo.DcSellInfoVo;
import com.bot.nft.module.dc.domain.vo.DcSellNftVo;
import com.bot.nft.module.dc.service.IDcSellInfoService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author RenXiaoZheng
 * @since 2024-01-24
 */
@RestController
@RequestMapping("/app/sell")
public class AppDcSellInfoController extends DcSellInfoController {

    @Resource
    IDcSellInfoService dcSellService;


    //分页查询市场藏品信息【市场一级列表】
    @RequestMapping("/{pageNo}/{pageSize}/querySellNft.do")
    public CommonResult<Page<DcSellNftVo>> selectDcBill(@PathVariable Integer pageNo,
                                                        @PathVariable Integer pageSize,
                                                        @RequestBody DcSellNftQueryBo dcSellNftQueryBo) {
        //分页查询二级市场艺术品
        Page<DcSellNftVo> dcSellNftVoPageInfo = dcSellService.pageMarketNft(pageNo, pageSize, dcSellNftQueryBo);
        //响应数据
        return CommonResult.data(dcSellNftVoPageInfo);
    }

    //查看市场艺术品【市场二级列表藏品信息】
    @RequestMapping("/{nftId}/viewSellNft.do")
    public CommonResult<DcSellNftVo> viewMarketNft(@PathVariable String nftId) {
        DcSellNftVo dcSellNftVo = dcSellService.viewMarketNft(nftId);
        return CommonResult.data(dcSellNftVo);
    }

    //分页查询寄售藏品信息【市场二级列表】
    @RequestMapping("/{pageNo}/{pageSize}/{nftId}/queryDCSellInfo.do")
    public CommonResult<Page<DcSellInfoVo>> queryDcSellInfo(@PathVariable Integer pageNo,
                                                            @PathVariable Integer pageSize,
                                                            @PathVariable String nftId) {

        Page<DcSellInfoVo> sellInfoVoPageInfo = dcSellService.pageDcSellInfo(pageNo, pageSize, nftId);
        return CommonResult.data(sellInfoVoPageInfo);
    }

    //查看寄售藏品信息【藏品详情】
    @RequestMapping("/{id}/viewDCSellInfo.do")
    public CommonResult<DcSellInfoVo> viewDcSellInfo(@PathVariable String id) {

        DcSellInfoVo dcSellInfoVo = dcSellService.viewDcSellInfo(id);
        return CommonResult.data(dcSellInfoVo);
    }

    //新增寄售藏品信息【藏品详情】
    @RequestMapping("/addDcSellInfo.do")
    public CommonResult addDcSellInfo(@RequestBody DcSellInfoBo dcSellInfo) {
        Boolean boo = dcSellService.insertSellInfo(dcSellInfo);
        CommonResult commonResult = new CommonResult();
        if (boo) {
            commonResult.setMsg("操作成功");
            commonResult.setCode(200);
        } else {
            commonResult.setMsg("操作失败");
            commonResult.setCode(500);
        }
        return commonResult;
    }

}
